﻿<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>FTP上传下载</title>
  <link rel="stylesheet" href="../static/css/home.css">
</head>
<body>
  <header>
    <h1>服务器目录信息</h1>
    <table>
      <thead>
        <tr>
          <th>同步目录</th>
          <th>文件大小</th>
          <th>同步状态</th>
          <th>删除目录</th>
          <th>同步操作</th>
          <th>忽略操作</th>
        </tr>
      </thead>
      <tbody>
        {% for ftp_file in ftp_files %}
        <tr class="ftp-file-row" id="{{ftp_file}}_99">
          <td class="ftp-file-name" id="{{ftp_file}}">{{ftp_file}}</td>
          {% if ftp_size_dict[ftp_file] != '文件夹' %}
          <td class="ftp-file-size" id="{{ftp_file}}_0">{{ftp_size_dict[ftp_file]}}字节</td>
          {% else %}
          <td class="ftp-file-size" id="{{ftp_file}}_0">文件夹</td>
          {% endif %}
          <td class="ftp-file-state" id="{{ftp_file}}_1">{{ftp_state_dict[ftp_file]}}</td>
          <td class="ftp-file-delete" id="{{ftp_file}}_2"><button onclick="deleteFile('{{ftp_file}}')">删除</button></td>
          {% if ftp_size_dict[ftp_file] != '文件夹' %}
          <td class="ftp-file-sync" id="{{ftp_file}}_3">
            <button onclick="localSync('{{ftp_file}}')">本地为主</button>
            <button onclick="ftpSync('{{ftp_file}}')">服务器为主</button>
          </td>
          {% else %}
          <td class="ftp-file-sync" id="{{ftp_file}}_3">文件夹无法同步</td>
          {% endif %}
          {% if ftp_size_dict[ftp_file] != '文件夹' %}
          <td class="ftp-file-ignore" id="{{ftp_file}}_4" onclick="changeState('{{ftp_ignore_dict[ftp_file]}}', '{{ftp_file}}')">{{ftp_ignore_dict[ftp_file]}}</td>
          {% endif %}
        </tr>
        {% endfor %}
      </tbody>
    </table>
    <div class="ftp-buttons">
      <button id="upload-btn">上传</button>
      <button id="back-btn">返回上一级</button>
      <button id="download-btn">下载</button>
      <button id="show-btn">查看历史记录</button>
    </div>
  </header>

  <main>
    <h1>本地文件目录</h1>
    <table>
      <thead>
        <tr>
          <th>同步目录</th>
        </tr>
      </thead>
      <tbody>
        {% for local_file in local_files %}
        <tr class="local-file-row" id="{{local_file}}_99">
          <td class="local-file-name" id="{{local_file}}">{{local_file}}</td>
        </tr>
        {% endfor %}
      </tbody>
    </table>
  </main>

  <script src="{{ url_for('static', filename='/js/jquery-3.6.4.min.js') }}"></script>
  <script src="{{ url_for('static', filename='/js/home.js') }}"></script>
</body>
</html>